import requests

def userLogin(phone, password):
    url = "https://testpassport.rabbitpre.com/api/sso/login"
    params = {"account": phone, "password": password, "fromType": "pc"}
    requests.packages.urllib3.disable_warnings()    #处理警告
    session = requests.session()
    response = session.post(url, json=params)
    if response.json().get("errorCode") != "SUCCESS":
        raise ValueError("登录失败")
    return session



try:
    session = userLogin(phone="****", password="****")

    user_url = "https://bws.test.rabbitpre.com/api/user"
    user_info = session.get(user_url, verify=False)
    print('user_id:', user_info.json()["data"]["userId"])

    org_url = "https://home.test.rabbitpre.com/api/workbench/org/getCompanyInfo"
    org_info = session.get(org_url, verify=False)
    print('org_id:', org_info.json()["data"]["org_id"])

except ValueError as error:
    print(error)

